// ignore_for_file: dangling_library_doc_comments, slash_for_doc_comments
import '../../module_code/login/models/login_model.dart';
import 'package:flutter/material.dart';

/*** 
 * @Author: Zhong
 * @Date: 2025-03-26 10:10:06
 * @LastEditors: Zhong zhongxiaodong@eenet.com
 * @LastEditTime: 2025-07-17 17:23:06
 * @FilePath: /wan_android_flutter/lib/common_code/utils/tools.dart
 * @Description: 
 */

class Tools {
  // 获取状态栏高度
  static double getStatusBarHeight(BuildContext context) {
    return MediaQuery.of(context).padding.top;
  }

  // 获取导航栏高度（默认AppBar）
  static double getNavigationBarHeight() {
    return AppBar().preferredSize.height;
  }

  // 获取导航栏 + 状态栏的总高度
  static double getTotalHeight(BuildContext context) {
    return getStatusBarHeight(context) + getNavigationBarHeight();
  }

  // 获取自定义AppBar的高度
  static double getCustomAppBarHeight(PreferredSizeWidget appBar) {
    return appBar.preferredSize.height;
  }

  // 获取自定义AppBar + 状态栏的总高度
  static double getCustomTotalHeight(
    BuildContext context,
    PreferredSizeWidget appBar,
  ) {
    return getStatusBarHeight(context) + getCustomAppBarHeight(appBar);
  }

  //判断用户是否登录
  static bool isUserLogin() {
    if (LoginModelData.loadCacheData() != null) {
      return true;
    } else {
      return false;
    }
  }

  //清除缓存数据
  static void clearCacheData() {
    //清除登录数据
    LoginModelData.clearCacheData();
  }
}
